<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php JHTML::_('behavior.tooltip'); ?>
<form action="index.php?option=com_articlecashrewards" method="post" name="adminForm">
<div id="submenu-box">
    <div class="t">
        <div class="t">
            <div class="t"></div>
        </div>
    </div>
    <div class="m">
        <ul id="submenu">
            <li>
                <a href="index.php?option=com_articlecashrewards&controller=approval&task=pendingreview"><?php echo JText::_('LABEL_PENDING');?></a>
            </li>
            <li>
                <a class="active" href="index.php?option=com_articlecashrewards&controller=listing&task=approved"><?php echo JText::_('LABEL_APPROVED');?></a>
            </li>
            <li>
                <a href="index.php?option=com_articlecashrewards&controller=rejected&task=rejected"><?php echo JText::_('LABEL_REJECTED');?></a>
            </li>
        </ul>
        <div class="clr"></div>
    </div>
    <div class="b">
        <div class="b">
            <div class="b"></div>
        </div>
    </div>
</div>
<table class="adminlist" cellspacing="1">
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'Num' ); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->rows ); ?>);" />
			</th>
			<th class="title">
				<?php echo JHTML::_('grid.sort', JText::_('LABEL_TITLE'), 'a.title', @$lists['order_Dir'], @$lists['order'] ); ?>
			</th>
			<th width="10%" class="title">
				<?php echo JHTML::_('grid.sort', JText::_('LABEL_SECTION'), 's.title', @$lists['order_Dir'], @$lists['order'] ); ?>
			</th>
			<th width="10%" class="title">
				<?php echo JHTML::_('grid.sort', JText::_('LABEL_CATEGORY'), 'cc.title', @$lists['order_Dir'], @$lists['order'] ); ?>
			</th>
			<th width="10%" class="title">
				<?php echo JHTML::_('grid.sort', JText::_('LABEL_AUTHOR'), 'u.username', @$lists['order_Dir'], @$lists['order'] ); ?>
			</th>
			<?php if ($this->acr_config[CONFIG_ENABLE_POINTS]=='1') : ?>
			<th width="5%" class="title">
                <?php
                $label = '';
                if (strcmp($this->acr_config[CONFIG_POINTS_SYSTEM], POINTS_SYSTEM_JOMSOCIAL) == 0){
                    $label = JText::_('LABEL_RATING');
                }else{
                    $label = JText::_('LABEL_POINTS');
                }
				echo JHTML::_('grid.sort', $label, 'acr.points', @$lists['order_Dir'], @$lists['order'] );
                ?>
			</th>
			<?php endif; ?>
			<th width="5%" class="title">
				<?php echo JHTML::_('grid.sort', JText::_('LABEL_CASH'), 'acr.cash', @$lists['order_Dir'], @$lists['order'] ); ?>
			</th>
			<th width="10%" class="title">
				<?php echo JHTML::_('grid.sort', JText::_('LABEL_REMARKS'), 'acr.remarks', @$lists['order_Dir'], @$lists['order'] ); ?>
			</th>
		</tr>
	</thead>
	<tbody>
		<?php
		if($this->rows){
			
			$k = 0;
			$i = 0;
			$user =& JFactory::getUser();
			foreach ($this->rows as $row){
				$access 	= JHTML::_('grid.access',   $row, $i );
				$checked 	= JHTML::_('grid.checkedout',   $row, $i );
		
				if ( $user->authorize( 'com_users', 'manage' ) ) {
					if ( $row->created_by_alias ) {
						$author = $row->created_by_alias;
					} else {
						$linkA 	= JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by );
						$author='<span class="editlinktip hasTip" title="'.JText::_( 'Edit User' ).'::'.$row->author.'">' .
								'<a href="'. $linkA .'">'. $row->author .'</a><span>';
					}
				} else {
					if ( $row->created_by_alias ) {
						$author = $row->created_by_alias;
					} else {
						$author = $row->author;
					}
				}
		
				// section handling
				if ($row->sectionid) {
					$row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid );
					$title_sec		= JText::_( 'Edit Section' );
				}
		
				// category handling
				if ($row->catid) {
					$row->cat_link 	= JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid );
					$title_cat		= JText::_( 'Edit Category' );
				}
				
				$href = JRoute::_('index.php?option=com_articlecashrewards&controller=process&cid='.$row->id.'&redirect=2');
				?>
				<tr class="<?php echo "row$k"; ?>">
					<td align="left">
						<?php echo $this->pagination->getRowOffset( $i); ?>
					</td>
					<td align="left">
						<?php echo $checked; ?>
					</td>
					<td align="left">
						<span class="editlinktip hasTip" title="<?php echo JText::_( 'Review Content' );?>::<?php echo $row->title; ?>">
							<a href="<?php echo $href; ?>"><?php echo $row->title; ?></a>
						</span>
					</td>
					<td align="left">
						<?php if ($row->sectionid) : ?>
						<span class="editlinktip hasTip" title="<?php echo $title_sec; ?>::<?php echo $row->section; ?>">
							<a href="<?php echo $row->sect_link; ?>"><?php echo $row->section; ?></a>
						</span>
						<?php endif; ?>
					</td>
					<td align="left">
						<?php if ($row->catid) : ?>
						<span class="editlinktip hasTip" title="<?php echo $title_cat; ?>::<?php echo $row->category; ?>">
							<a href="<?php echo $row->cat_link; ?>" title="<?php echo $row->category; ?>"><?php echo $row->category; ?></a>
						</span>
						<?php endif; ?>
					</td>
					<td align="left">
						<?php echo $author; ?>
					</td>
					<?php if ($this->acr_config[CONFIG_ENABLE_POINTS]=='1') : ?>
					<td align="left">
						<?php echo $row->points; ?>
					</td>
					<?php endif; ?>
					<td align="left">
						<?php echo $row->cash; ?>
					</td>
					<td align="left">
						<?php echo $row->remarks; ?>
					</td>
				</tr>
				<?php
				$k = 1 - $k;
				$i++;
			}
		}
		?>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="9"><?php echo $this->pagination->getListFooter(); ?></td>
		</tr>
	</tfoot>
</table>
<input type="hidden" name="option" value="com_articlecashrewards" />
<input type="hidden" name="controller" value="listing" />
<input type="hidden" name="task" value="approved" />
<input type="hidden" name="pnlimitstart" value="<?php echo $this->pagination->limitstart; ?>" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
